473,433 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,433 software developers and data experts.

Detect mouse leaving from a list view item

Hi all,
I am working on a windows application with a list view on a form.
Now I wanted to show hand cursor when mouse is over list view item and
default(arrow) cursor at other places.

List view's ItemMouseHover event can tell me that mouse is on the
item and here I can change my cursor to hand. But I have no clue to
change it back to default cursor when mouse is moved out of the list
view item.

How can I detect that mouse is moved away/out of the list view
item??

I have also tried to use HitTest method of the list view in the
MouseMove event but it is causing lots of overhead and sometimes hangs
the application. So I am not using this option.
Can someone give me an idea how to achieve it.

Thanks!!
Oct 8 '08 #1
2 5484
This seems to work fine for me. Never locks up. I dont know if you had an
issue with constantly setting the cursor. Thats why i check it before setting
it:

private void listView1_MouseMove(object sender, MouseEventArgs e)
{
if (listView1.HitTest(e.X, e.Y).Item == null && (this.Cursor !=
Cursors.Default))
{
this.Cursor = Cursors.Default;
}
else if (this.Cursor == Cursors.Default)
{
this.Cursor = Cursors.Hand;
}
}

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Mohit" wrote:
Hi all,
I am working on a windows application with a list view on a form.
Now I wanted to show hand cursor when mouse is over list view item and
default(arrow) cursor at other places.

List view's ItemMouseHover event can tell me that mouse is on the
item and here I can change my cursor to hand. But I have no clue to
change it back to default cursor when mouse is moved out of the list
view item.

How can I detect that mouse is moved away/out of the list view
item??

I have also tried to use HitTest method of the list view in the
MouseMove event but it is causing lots of overhead and sometimes hangs
the application. So I am not using this option.
Can someone give me an idea how to achieve it.

Thanks!!
Oct 8 '08 #2
Hi,
Thanks Ciaran for your response.

Even after adding up cursor check it is still causing up to lots of
overhead and hanging up the application. CPU utilization clock is
showing up 100% usage when mouse is moved over the list view and
various items for a considerable amount of time.

Is there some other alternative exist??
Oct 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eitan | last post by:
Hello, I am creating a new window class based on CWnd. I am placing it on the View (CFormView). How can I get the notification or any other indication that the cursor/mouse is not on this...
0
by: Eitan | last post by:
Hello, I am creating a new window class based on CWnd. I am placing it on the View (CFormView). How can I get the notification or any other indication that the cursor/mouse is not on this...
7
by: who be dat? | last post by:
I need some help here. I'm creating a list on a page where the list is created from a dataset with two tables linked with a datarelation. The first table is a list of groups while the second...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
3
by: Steve Long | last post by:
I hope this isn't too stupid of a question but I'm looking for a way to change an item in a listview control when the mouse moves over it. I'd like to change its color and underline it for a...
5
by: Pavan | last post by:
My goal is to accomplish the tooltip functionality for all the neodes in a tree view and i have the following three Events in my C# application. Name of my TreeView Control (AITreeView) 1)...
2
by: Roberto Reale | last post by:
While developing a drag&drop enabled application I found out this "strange" behaviour: if I put a message box into the QueryContinueDrag event handler the message box is shown but the mouse cursor...
1
by: Sim | last post by:
Hello NG, I try to use drag and drop function between two list views. For this I found following code: ...
2
by: james | last post by:
Hello I'm implementing drag and drop between two listviews (in detail view mode). When I drag an item from box a to box b, I then process information relating to the two items. The item from...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.